//
//  NotificationHelper.m
//  carcareIOS
//
//  Created by ileo on 15/8/26.
//  Copyright (c) 2015年 baozun. All rights reserved.
//

#import "NotificationHelper.h"
#import "AIUserInfo.h"
@interface NotificationHelper()

@end

@implementation NotificationHelper

+(void)configuration{
    //消息推送注册
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
}

+(void)dealWithDeviceToken:(NSData *)deviceToken{
    NSMutableString *token = [NSMutableString stringWithFormat:@"%@", deviceToken];
    [token deleteCharactersInRange:(NSRange){0,1}];
    [token deleteCharactersInRange:(NSRange){token.length - 1,1}];
    USERINFO.token = token;
}

+(void)dealWithFailError:(NSError *)error{
    DLog(@"Failed to get token, error:%@", error);
}

+(void)dealWithReceiveInfo:(NSDictionary *)info{
    DLog(@"Receive remote notification : %@",info);
    NSString *type = info[@"type"];
    if (type) {
        if ([type isEqualToString:@"New_Violations"]) {//新违章
//            TipsView *tips = [TipsView textTipsWithTitle:@"推送消息" lightTitles:@[info[@"aps"][@"alert"]]];
//            [tips addLeftButton:@"取消" clickLeft:^{
//                [AlertMgr dismiss:TYPE_VIEW_ALERT];
//            } rightButton:@"查看" clickRight:^{
//                [AlertMgr dismiss:TYPE_VIEW_ALERT];
//            }];
//            [AlertMgr showView:tips];
        }
    }
    
}

@end
